<?php require_once '../yubiphpbase/appinclude.php';
require_once '../yubiphpbase/yubi_lib.php';
include 'head.htm';
$srctext = getHttpVal('srctext', '');
$srcfmt = getHttpVal('srcfmt', 'P');
//if (strlen($otp) > 0) {
//	$devId = substr($otp, 0, 12);
//	$devId_b64 = modhexToB64($devId);
//	echo '<h2>Your Yubikey token ID is:</h2><ul>'.
//		'<li>modhex encoded: ' . $devId .
//		'<li>base64 encoded: ' . $devId_b64 .
//		'<li>hex encoded: ' . b64ToHex($devId_b64) . 
//		"</ul>";
//} else {
//	echo '<h2>Yubikey Converter</h2>';
//}

if (strlen($srctext) > 0) {
	
	$b64txt = $srctext;
	if($srcfmt == "P") {
		$b64txt = base64_encode($srctext);
	} else if ($srcfmt == "H") {
		$b64txt = hexToB64($srctext);
	} else if ($srcfmt == "M") {
		$b64txt = modhexToB64($srctext);
	} 
	
	$plaintxt = $srctext;
	$devId_b64 = modhexToB64($devId);
	echo '<h2>Your source string is:</h2><ul>'.
		'<li>plain text: ' . base64_decode($b64txt) .
		'<li>modhex encoded: ' . b64ToModhex($b64txt) .
		'<li>base64 encoded: ' . $b64txt .
		'<li>hex encoded: ' . b64ToHex($b64txt) . 
		"</ul>";
} else {
	echo '<h2>Format Converter</h2>';
}
?>
<p><br>

<form action=converter.php method=post autocomplete=off>
	<b>Source format:</b>&nbsp;
	<INPUT TYPE=RADIO NAME="srcfmt" VALUE="P" CHECKED>plain&nbsp;
	<INPUT TYPE=RADIO NAME="srcfmt" VALUE="B">base64&nbsp;
	<INPUT TYPE=RADIO NAME="srcfmt" VALUE="H">hex&nbsp;
	<INPUT TYPE=RADIO NAME="srcfmt" VALUE="M">modhex&nbsp;<BR><BR>
	<b>String:</b>&nbsp;
	<input name=srctext value="" size=50 maxlength=50><p>
	<input type=submit value="Convert to all formats">
</form>
